package com.wangp.springbootsource.pro;

import com.wangp.springbootsource.util.ColorPrintUtil;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

/**
 * <pre>
 * classname ResultCommandLineRunner
 * description
 * </pre>
 *
 * @author wangpeng
 * @date 2020/9/27 19:22
 **/
@Component
public class ResultCommandLineRunner implements CommandLineRunner, EnvironmentAware, MyAware {

    private Environment environment;

    private Flag flag;

    @Override
    public void run(String... args) throws Exception {
        System.out.println("DefaultKey -->  " + environment.getProperty("key"));
        System.out.println("age -->  " + environment.getProperty("avg.age"));
        System.out.println("path -->  " + environment.getProperty("system.path"));
        ColorPrintUtil.redPrint(flag.isCanOperation() + "\u001b[0m");
    }

    @Override
    public void setEnvironment(Environment environment) {
        this.environment = environment;
    }

    @Override
    public void setFlag(Flag flag) {
        this.flag = flag;
    }
}
